home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Ghost 1.0 / source / Ghost ƒ / MSG Shell ƒ / msg integrity.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  2.1 KB  |  81 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        msg integrity.c
  4.  
  5. Purpose:    This module implements a quick-and-dirty integrity check;
  6.             compare the resource fork and map length to stored values.
  7.             (Drop the completed application on "Prepare" to store
  8.             these values in the right place.)
  9.  
  10.  
  11. Ghost -=- a classic word-building challenge
  12. Copyright (C) 1993 Mark Pilgrim
  13.  
  14. This program is free software; you can redistribute it and/or modify
  15. it under the terms of the GNU General Public License as published by
  16. the Free Software Foundation; either version 2 of the License, or
  17. (at your option) any later version.
  18.  
  19. This program is distributed in the hope that it will be useful,
  20. but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22. GNU General Public License for more details.
  23.  
  24. You should have received a copy of the GNU General Public License
  25. along with this program in a file named "GNU General Public License".
  26. If not, write to the Free Software Foundation, 675 Mass Ave,
  27. Cambridge, MA 02139, USA.
  28.  
  29. \**********************************************************************/
  30.  
  31. #include "msg integrity.h"
  32. #include "msg graphics.h"
  33. #include "msg dialogs.h"
  34.  
  35. void DoIntegrityCheck(void)
  36. {
  37.     int                thisFile;
  38.     long            count;
  39.     long            resDataLength, checkData;
  40.     long            resMapLength, checkMap;
  41.     Boolean            problem;
  42.     
  43.     problem=FALSE;
  44.     FlushVol(0L, 0);
  45.     OpenRF(CurApName, 0, &thisFile);
  46.     if (!problem)
  47.     {
  48.         SetFPos(thisFile, 1, 8L);
  49.         count=4L;
  50.         problem=(FSRead(thisFile, &count, (Ptr)(&resDataLength))!=noErr);
  51.     }
  52.     if (!problem)
  53.     {
  54.         SetFPos(thisFile, 1, 12L);
  55.         count=4L;
  56.         problem=(FSRead(thisFile, &count, (Ptr)(&resMapLength))!=noErr);
  57.     }
  58.     if (!problem)
  59.     {
  60.         SetFPos(thisFile, 1, 144L);
  61.         count=4L;
  62.         problem=(FSRead(thisFile, &count, (Ptr)(&checkData))!=noErr);
  63.     }
  64.     if (!problem)
  65.     {
  66.         SetFPos(thisFile, 1, 148L);
  67.         count=4L;
  68.         problem=(FSRead(thisFile, &count, (Ptr)(&checkMap))!=noErr);
  69.     }
  70.     
  71.     if (!problem)
  72.         problem=((resDataLength!=checkData) || (resMapLength!=checkMap));
  73.  
  74.     if (problem)
  75.     {
  76.         PositionDialog('ALRT', integrityCheckFailAlert);
  77.         StopAlert(integrityCheckFailAlert,0L);
  78.         ExitToShell();
  79.     }
  80. }
  81.